Create Resource
Introduction
The following Assetic REST API endpoint may be used to create a new resource.
- POST /api/v2/resource
The Assetic REST API GET /api/v2/resource may be used to check if a resource already exists prior to attempting to create a new resource. A filter on fields such as DisplayName or FirstName/Surname or Company, or External Id may be used to check. The article Get Resource describes this API in further detail.
Resource Definition
When defining a new resource the following properties are relevant:
Field | Description | Type | Mandatory |
DisplayName | If NULL the displayName is set as a concatenation of the FirstName, Surname, and Company. | char(100) | Conditional |
FirstName | First name of person | char(50) | Conditional |
Surname | Family name of person | char(50) | Conditional |
Company | Company. Not required unless both First Name and Surname are empty | char(100) | Conditional |
Position | Role withing the company | String | Optional |
Status | "Active" or "Inactive", use "Active" | String | Optional |
Types | An array of "Requestor Type". | Array of Object | Optional |
ExternalID | An external reference number | String | Optional |
Phone | Phone number | String | Optional |
Mobile | Mobile phone number | String | Optional |
Fax | Fax number | String | Optional |
Email address | String | Optional | |
AddressComment | General comment about address | String | Optional |
Address | Address | Address object | Optional |
The DisplayName is limited to 100 characters, so if the generated name is greater than 100 characters the API will return an error. It is prudent therefore to ensure the "DisplayName" is set in the request payload rather than relying on it to be generated.
Requestor Type
Requestor type object has 2 properties 'Id' (Integer) and 'Type' (String).
The "Type" is used is the payload, not the "Id"
Id | Type |
2 | Team |
4 | Customer |
8 | Contractor |
16 | Employee |
32 | Company |
Sample Payload
Sample Request
The following is a typical payload used to create a new "Contractor" resource:
{
"DisplayName": "Ash Barty (A1 Electrical)",
"FirstName": "Ashleigh",
"Surname": "Barty",
"Company": "A1 Electrical",
"Phone": "04 456 4566",
"Mobile": "0417 455 678",
"Email": "ab@example.com",
"AddressComment": "23 Tennis Avenue Brisbane",
"ExternalID": "No1",
"Status": "Active",
"Types": [{"Type": "Contractor"}],
}
Sample Response
The response is returned as a collection and includes the generated unique Id:
{
"Data": [
{
"Id": "2b0f46b4-9b25-47a4-82e2-7e01b3e31147",
"DisplayName": "Ash Barty (A1 Electrical)",
"FirstName": "Ashleigh",
"Surname": "Barty",
"Company": "A1 Electrical",
"Position": null,
"Phone": "04 456 4566",
"Mobile": "0417 455 678",
"Fax": null,
"Email": "ab@example.com",
"AddressComment": "23 Tennis Avenue Brisbane",
"ExternalID": "No1",
"StatusId": 1,
"Status": "Active",
"Types": [
{
"Id": 8,
"Type": "Contractor",
}
],
}
],
"Total": 1
}